CREATE PROCEDURE [AsignarActor]
(
@idActor INT,
@idCasodeUso VARCHAR(50)
)
AS
BEGIN
  
	SET NOCOUNT ON;
	INSERT INTO CASO_ACTOR 
	VALUES (@idCasodeUso,@idActor);

END



GO


CREATE PROCEDURE [CambiarEstatusActor]
(
@idActor INT,
@estatusNuevo VARCHAR(100)
)
AS
BEGIN
SET NOCOUNT ON;
UPDATE ACTOR

SET ACTOR.ESTATUSACTOR=@estatusNuevo

WHERE ACTOR.ID_ACTOR=@idActor;
  -- routine body goes here, e.g.
  -- SELECT 'Navicat for SQL Server'
END




GO

CREATE PROCEDURE [ConsultarActor]
(
@idProyecto int
)
AS
BEGIN

SET NOCOUNT ON;

SELECT ACTOR.ID_ACTOR,
			 ACTOR.NOMBREACTOR,
			 ACTOR.DESCRIPCIONACTOR,
			 ACTOR.ESTATUSACTOR

FROM ACTOR 

WHERE ACTOR.IDPROYECTO=@idProyecto;
  -- routine body goes here, e.g.
  -- SELECT 'Navicat for SQL Server'
END




GO


CREATE PROCEDURE [ConsultarActorCasoDeUso]
(
@idCasoDeUso INT
)
AS
BEGIN
SET NOCOUNT ON;
SELECT ACTOR.ID_ACTOR,
			 ACTOR.NOMBREACTOR

FROM ACTOR, CASO_ACTOR

WHERE CASO_ACTOR.ID_ACTOR=ACTOR.ID_ACTOR AND
CASO_ACTOR.ID_CU=@idCasoDeUso;

END




GO


CREATE PROCEDURE [ConsultarDetalleActor]
(
@idActor INT
)
AS
BEGIN

	SET NOCOUNT ON;
	SELECT ACTOR.NOMBREACTOR, ACTOR.DESCRIPCIONACTOR, ACTOR.ESTATUSACTOR
	FROM ACTOR
	WHERE ACTOR.ID_ACTOR=@idActor;
	

END



GO

CREATE PROCEDURE [EliminarActor]
(
@idActor int
)
AS
BEGIN
SET NOCOUNT ON;

DELETE 
FROM CASO_ACTOR
WHERE CASO_ACTOR.ID_ACTOR=@idActor;

DELETE 
FROM ACTOR
WHERE ACTOR.ID_ACTOR=@idActor;
  -- routine body goes here, e.g.
  -- SELECT 'Navicat for SQL Server'
END




GO


CREATE PROCEDURE [InsertarActor]
(
@idProyecto INT,
@nombreActor VARCHAR(50),
@descripcionActor VARCHAR(150),
@estatusActor VARCHAR(50)
)
AS
BEGIN

SET NOCOUNT ON;

INSERT INTO ACTOR
VALUES (@idProyecto,@nombreActor,@descripcionActor,@estatusActor);


END




GO

CREATE PROCEDURE [ModificarActor]
(
@idActor INT,
@nombreActor VARCHAR(50),
@descripcionActor VARCHAR(150),
@estatusActor VARCHAR(50)
)
AS
BEGIN

	SET NOCOUNT ON;
	UPDATE ACTOR 
	SET ACTOR.NOMBREACTOR=@nombreActor, ACTOR.DESCRIPCIONACTOR=@descripcionActor, ACTOR.ESTATUSACTOR=@estatusActor
	WHERE ACTOR.ID_ACTOR=@idActor;
	
END



GO


CREATE PROCEDURE [ObtenerIdActor]
AS
BEGIN


       SET NOCOUNT ON;

 SELECT TOP 1 ACTOR.ID_ACTOR

       FROM ACTOR

       ORDER BY ACTOR.ID_ACTOR DESC

               

END


GO


CREATE PROCEDURE [ProyectoActual]
(
	@nombre VARCHAR(50)

)

AS
BEGIN
			SET NOCOUNT ON;

			SELECT PROYECTO.IDPROYECTO
			
			FROM PROYECTO

			WHERE PROYECTO.STATUS='Activo' AND
						PROYECTO.NOMBRE_PROYECTO=@nombre;


END




GO


CREATE PROCEDURE [QuitarActorCasoDeUso]
(
@idActor INT,
@idCasodeUso VARCHAR(50)
)
AS
BEGIN
  
	SET NOCOUNT ON;
	DELETE FROM CASO_ACTOR	
	WHERE CASO_ACTOR.ID_ACTOR=@idActor AND
	CASO_ACTOR.ID_CU=@idCasodeUso;
	
END


GO


CREATE PROCEDURE [RequerimientosProyecto]
(
		@idProyecto int
)
AS
BEGIN
			SET NOCOUNT ON;
			SELECT REQUERIMIENTO.ID_REQUERIMIENTO,
						 REQUERIMIENTO.CODIGO_REQ
             
			FROM REQUERIMIENTO

			WHERE REQUERIMIENTO.IDPROYECTO=@idProyecto;
	
END




GO
